package com.be.beadmin.basicData.controller;

import com.be.beadmin.basicData.entity.Warehouse;
import com.be.beadmin.common.entity.PageEntity;
import com.be.beadmin.basicData.service.WarehouseService;
import com.be.beadmin.basicData.dto.input.WarehouseQueryCriteria;
import com.be.beadmin.basicData.dto.input.WarehouseDto;
import org.springframework.data.domain.Pageable;
import com.be.beadmin.common.utils.ResultModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
* @author chenwei
* @date 2022-12-22
**/
@RestController
public class WarehouseController {

    @Autowired
    private  WarehouseService warehouseService;


    @PostMapping(value = "/product/getWarehouseByPage")
    public ResultModel getWarehouseByPage(@RequestBody PageEntity pageEntity)  {
        return ResultModel.success(warehouseService.getWarehouseByPage(pageEntity)) ;
    }

    @PostMapping("/product/addWarehouse")
    public ResultModel addWarehouse(@RequestBody WarehouseDto warehouseDto){
        warehouseService.addWarehouse(warehouseDto);
        return ResultModel.success(ResultModel.ADD);
    }

    @PostMapping("/product/delWarehouse")
    public ResultModel delWarehouse(@RequestBody WarehouseDto warehouseDto){
        warehouseService.delWarehouse(warehouseDto.getId());
        return ResultModel.success(ResultModel.DELETE);
    }


    @PostMapping("/product/updateWarehouse")
    public ResultModel updateWarehouse(@RequestBody WarehouseDto warehouseDto){
        warehouseService.updateWarehouse(warehouseDto);
        return ResultModel.success(ResultModel.UPDATE);
    }
}